/*
 * Copyright (C) 2011, EADS France
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.interpreter;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public class Transaction {
    private String description;
    private List<TransactionElement> elements;

    public String getDescription() { return description; }
    
    public Transaction(String description) {
        this.description = description;
        this.elements = new ArrayList<TransactionElement>();
    }

    public void addElement(TransactionElement element) { elements.add(element); }

    public void undo() throws XOWLException {
        for (int i=elements.size() - 1; i!=-1; i--)
            elements.get(i).undo();
    }
    public void redo() throws XOWLException {
        for (int i=0; i!=elements.size(); i++)
            elements.get(i).redo();
    }
}
